package hang.xipujewelWeb.entity.app;

import hang.xipujewelWeb.entity.IdEntity;
import hang.xipujewelWeb.entity.account.User;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "xipu_order")
public class Order extends IdEntity {

	private User user;//该订单属于哪该用户
	private List<Jewel> jewels = new ArrayList<Jewel>();//该订单下的所有钻石
	private List<Ring> rings = new ArrayList<Ring>();
	private int status;//是否已处理，0：未处理，1：已处理
	private Date submitTime;
	private String orderNum;
	private float sumPrice;
	private String recieveUser;//接收者
	private String phone;//手机
	private String remark;//备注
	private String cell; //座机
	private String fax;//传真
	private String email;//邮箱
	private String address; //街道

	public String getCell() {
		return cell;
	}

	public void setCell(String cell) {
		this.cell = cell;
	}

	public String getFax() {
		return fax;
	}

	public void setFax(String fax) {
		this.fax = fax;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getRecieveUser() {
		return recieveUser;
	}

	public void setRecieveUser(String recieveUser) {
		this.recieveUser = recieveUser;
	}

	@Transient
	public float getSumPrice() {
		return sumPrice;
	}

	public void setSumPrice(float sumPrice) {
		this.sumPrice = sumPrice;
	}

	public String getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(String orderNum) {
		this.orderNum = orderNum;
	}

	public Date getSubmitTime() {
		return submitTime;
	}

	public void setSubmitTime(Date submitTime) {
		this.submitTime = submitTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	@ManyToOne(cascade = CascadeType.REFRESH)
	@JoinColumn(name = "USER_ID")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@ManyToMany
	@JoinTable(name = "Order_Jewel", joinColumns = { @JoinColumn(name = "Order_ID", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "Jewel_ID", referencedColumnName = "id") })
	public List<Jewel> getJewels() {
		return jewels;
	}

	public void setJewels(List<Jewel> jewels) {
		this.jewels = jewels;
	}

	@ManyToMany
	@JoinTable(name = "Order_Ring", joinColumns = { @JoinColumn(name = "Order_ID", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "Ring_ID", referencedColumnName = "id") })
	public List<Ring> getRings() {
		return rings;
	}

	public void setRings(List<Ring> rings) {
		this.rings = rings;
	}

}
